package com.softWang.system.controller;

import com.softWang.common.aop.annotation.SysOperationLog;
import com.softWang.system.constants.SysModel;
import com.softWang.system.controller.vo.systemOperatorLog.SystemOperatorLogDetailResult;
import com.softWang.system.controller.vo.systemOperatorLog.SystemOperatorLogQueryAllParam;
import com.softWang.system.controller.vo.systemOperatorLog.SystemOperatorLogQueryAllResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.List;

import com.softWang.common.response.PageBean;
import com.softWang.common.request.Idparam;
import com.softWang.common.response.ResponseResult;
import com.softWang.system.po.SystemOperatorLog;
import com.softWang.system.service.SystemOperatorLogService;

@Api(value="系统操作日志管理",tags="系统操作日志管理")
@Validated
@RestController
@RequestMapping("/system/systemOperatorLog")
public class SystemOperatorLogController {
     @Resource
     private SystemOperatorLogService systemOperatorLogService;

     @PreAuthorize("@ss.hasPermi('system:operatorLog:query')")
     @ApiOperation(value="列表(分页)")
     @RequestMapping(value = "/query", method = RequestMethod.POST)
     public ResponseResult<PageBean<SystemOperatorLogQueryAllResult>> queryall(@RequestBody @Validated SystemOperatorLogQueryAllParam param, HttpServletRequest request) {
         List<SystemOperatorLogQueryAllResult> results=systemOperatorLogService.queryall(param);
         PageBean page=new PageBean(results);
         return ResponseResult.success(page);
     }

     @PreAuthorize("@ss.hasPermi('system:operatorLog:detail')")
     @ApiOperation(value="查看详情")
     @RequestMapping(value = "/detail", method = RequestMethod.POST)
     public ResponseResult<SystemOperatorLogDetailResult> detail(@RequestBody @Validated Idparam idparam) {
         SystemOperatorLogDetailResult result = new SystemOperatorLogDetailResult();
         SystemOperatorLog entity = systemOperatorLogService.getById(idparam.getId());
         BeanUtils.copyProperties(entity, result);
         return ResponseResult.success(result);
     }

     @PreAuthorize("@ss.hasPermi('system:operatorLog:del')")
     @ApiOperation(value="删除")
     @SysOperationLog(value = "删除操作日志", model = SysModel.LOG_MANAGE)
     @RequestMapping(value = "/del", method = RequestMethod.POST)
     public ResponseResult del(@RequestBody @NotEmpty(message = "ids 不能为空") List<@NotNull(message = "ids 不能为空") Long> ids, HttpServletRequest request) {
         systemOperatorLogService.del(ids);
         return ResponseResult.success();
     }
}